<?php

use Illuminate\Http\Request;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

Route::middleware('auth:api')->get('/user', function (Request $request) {
    return $request->user();
});
//Route::group(['namespace' => 'Api','prefix'=>'api'],function (){
//    Route::post('/posts','PostController@listPosts');
//});
Route::group(['namespace' => 'Api'],function (){
    Route::any('/posts', 'PostController@listPosts');
    Route::any('/tags', 'CategoryController@listTags');
    Route::any('/article', 'PostController@article');
    Route::any('/categorys','CategoryController@listCates');
    Route::any('/pages','PageController@listPages');
    Route::any('/search','PostController@searchPost');
    Route::any('/cates','PostController@getCates');
    Route::any('/commit','CommentController@commit');
    Route::any('/comments','CommentController@comments');
});

Route::group(['namespace'=>'Admin','prefix'=>'admin'],function (){

    Route::post('/upload','FileController@upload');

    Route::group(['prefix'=>'category'],function (){
        Route::any('/search','CategoryController@search');
        Route::any('/list','CategoryController@listCates');
        Route::any('/collections','CategoryController@catesCollections');
    });

    Route::group(['prefix'=>'page'],function (){
        Route::any('/add','PageController@add');
    });
});